/*

* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Smart-Shop开源商城系统/ Java商城-首选电商平台系统 请务必保留此注释头信息
* |     开源地址: https://gitee.com/ningbo-qishan/gruul-mall
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     可正常分享和学习源码,未经授权 不可商用！
* |     商业版中台购买/开源版商业授权 联系技术客服
* |     官网:  https://www.73app.cn/
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Copyright (c) 2016-2999 宁波启山智软科技有限公司
* |     版权所有 ,侵权必究！
* ------------------------------------------------------------------------

*/
package com.medusa.gruul.discount.web.controller.manager;


import com.medusa.gruul.common.core.util.PageUtils;
import com.medusa.gruul.common.core.util.Result;
import com.medusa.gruul.discount.api.model.dto.manager.FullScaleDto;
import com.medusa.gruul.discount.api.model.param.manager.FullScaleParam;
import com.medusa.gruul.discount.api.model.vo.manager.FullScaleSimpleVo;
import com.medusa.gruul.discount.service.manager.IFullScaleService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 满减活动 前端控制器
 * </p>
 *
 * @author lcysike
 * @since 2019-12-09
 */
@RestController
@RequestMapping("/manager/full/scale")
public class FullScaleController {

    @Autowired
    private IFullScaleService fullScaleService;

    /**
     * 满减活动信息列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "满减活动信息列表")
    public Result<PageUtils> getFullScaleList(FullScaleParam fullScaleParam) {
        PageUtils pageUtils = new PageUtils(fullScaleService.getFullScaleList(fullScaleParam));
        return Result.ok(pageUtils);
    }

    /**
     * 获取单张满减活动信息
     */
    @GetMapping("/get/{id}")
    @ApiOperation(value = "单条满减活动信息")
    public Result<FullScaleSimpleVo> getSimpleFullScale(@ApiParam(value = "满减活动id", required = true) @PathVariable("id") Long id) {
        FullScaleSimpleVo fullScaleSimpleVo = fullScaleService.getSimpleFullScale(id);
        return Result.ok(fullScaleSimpleVo);
    }

    /**
     * 满减活动新增
     */
    @PostMapping("/add")
    @ApiOperation(value = "满减活动新增")
    public Result addFullScale(@RequestBody @Validated FullScaleDto fullScaleDto) {
        fullScaleService.addFullScale(fullScaleDto);
        return Result.ok();
    }

    /**
     * 满减活动修改
     */
    @PutMapping("/update")
    @ApiOperation(value = "满减活动修改")
    public Result updateFullScale(@RequestBody @Validated FullScaleDto fullScaleDto) {
        fullScaleService.updateFullScale(fullScaleDto);
        return Result.ok();
    }

    /**
     * 关闭/启用满减活动
     */
    @PutMapping("/changeStatus/{status}")
    @ApiOperation(value = "关闭/启用满减活动")
    public Result changeFullScaleStatus(@ApiParam(value = "满减活动ids", required = true) @RequestBody Long[] ids,
                                     @ApiParam(value = "满减活动状态值", required = true) @PathVariable("status") Integer status) {
        fullScaleService.changeFullScaleStatus(ids, status);
        return Result.ok();
    }

    /**
     * 满减活动删除
     */
    @DeleteMapping("/delete/{ids}")
    @ApiOperation(value = "满减活动删除(单个与批量共用)")
    public Result deleteFullScaleList(@ApiParam(value = "满减活动ids", required = true) @PathVariable(name = "ids") Long[] ids) {
        fullScaleService.deleteFullScaleList(ids);
        return Result.ok();
    }

}
